package b4.model.basic
{
	import flash.events.EventDispatcher;
	import flash.utils.describeType;
	
	public class Model extends EventDispatcher
	{
		public function Model()
		{
		}
		
		public function loadbyObject(object:Object):void
		{
			if (object == null)
				return;
			var instanceInfo:XML = describeType(this);
			var properties:XMLList = instanceInfo..accessor.(@access != "writeonly") + instanceInfo..variable;
			for each (var propertyInfo:XML in properties) {
				var propertyName:String = propertyInfo.@name;
				if (object.hasOwnProperty(propertyName))
				{
					if (propertyInfo.@type == "Boolean")
					{
						this[propertyName] = (object[propertyName] == "true" || object[propertyName] == "1" || object[propertyName] == 1 || object[propertyName] == true) ? true : false;
					}
					else
					{
						this[propertyName] = object[propertyName];
					}
				}
			}
		}
	}
}